from rest_framework.pagination import PageNumberPagination
from .response import JsonResponse
from rest_framework.response import Response
from collections import OrderedDict


class PageNumberPagination(PageNumberPagination):
    page_size = 10   # default page size
    page_size_query_param = 'size'  # ?page=xx&size=??
    max_page_size = 10000  # max page size

    def get_paginated_response(self, data):

        return Response(OrderedDict([
            ('count', self.page.paginator.count),
            ('current', self.page.number),
            ('next', self.get_next_link()),
            ('previous', self.get_previous_link()),
            ('results', data),
        ]))
